<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="客户">
        <el-select
          size="small"
          clearable
          v-model="formInline.customerId"
          placeholder="请选择"
        >
          <el-option
            v-for="type in customerIdArr"
            :label="type.customerName"
            :value="type.customerId"
            :key="type.customerId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="代理人">
        <el-select
          size="small"
          clearable
          v-model="formInline.agentId"
          placeholder="请选择"
        >
          <el-option
            v-for="type in agentIdArr"
            :label="type.agentName"
            :value="type.agentId"
            :key="type.agentId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="挂靠城市">
        <el-cascader
          size="small"
          :options="options"
          clearable
          v-model="selectedOptions"
          @change="handleChange"
          ref="shengshi"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="时间">
        <el-date-picker
          size="small"
          v-model="dataValue"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="dataChange"
          value-format="yyyy-MM-dd"
          clearable
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-search"
          @click="search"
          >搜索</el-button
        >
        <el-button
          size="small"
          type="primary"
          icon="el-icon-plus"
          @click="handleEdit()"
          >添加</el-button
        >
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table
      size="small"
      :data="listData"

      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >
      <el-table-column
        sortable
        prop="orderEntity.orderId"
        label="订单ID"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="totalPepleCount"
        label="挂靠城市"
        width=""
      >
        <template slot-scope="scope">
          <div>
            {{
              scope.row.orderEntity.affiliatedProvinceTxt +
              "/" +
              scope.row.orderEntity.affiliatedCityTxt
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.customerName"
        label="客户名称"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.agentName"
        label="代理人名称"
        width=""
      >
        <template slot-scope="scope">
          <span>
            {{ computerAgentName(scope.row) }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.wage"
        label="工资"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.payDate"
        label="发薪日期"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.orderPrice"
        label="订单价格"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.orderProfits"
        label="订单利润"
        width=""
        v-if="isShowOrderMoney"
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.affiliatedTotalMonth"
        label="订单月数"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.affiliatedTotalPeople"
        label="订单人数"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.orderStartDate"
        label="订单开始时间"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.orderEndDate"
        label="订单结束时间"
        width=""
      >
      </el-table-column>
      <el-table-column
        sortable
        prop="orderEntity.createTime"
        label="创建时间"
        width=""
      >
      </el-table-column>
      <el-table-column sortable prop="orderEntity.remark" label="备注" width="">
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <!-- <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination
      v-bind:child-msg="pageparm"
      @callFather="callFather"
    ></Pagination>
    <!-- 编辑界面 -->
    <el-dialog
      :title="title"
      :visible.sync="editFormVisible"
      width="800px"
      @click="closeDialog"
      :close-on-click-modal="false"
    >
      <el-form
        label-width="120px"
        :model="editForm"
        :rules="rules"
        ref="editForm"
      >
        <el-form-item label="客户姓名" prop="customerName">
          <el-select
            size="small"
            v-model="editForm.orderEntity.customerId"
            clearable
            placeholder="请选择客户"
          >
            <el-option
              v-for="type in customerIdArr"
              :label="type.customerName"
              :value="type.customerId"
              :key="type.customerId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="挂靠地区:">
          <el-cascader
            size="small"
            :options="options"
            v-model="selectedOptions2"
            clearable
            @change="gkHandleChange"
            ref="guakaoSS"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="工资">
          <el-input
            size="small"
            v-model="editForm.orderEntity.wage"
            type="number"
            auto-complete="off"
            placeholder="请输入工资"
          ></el-input>
        </el-form-item>
        <el-form-item label="发薪日期">
          <el-input
            size="small"
            v-model="editForm.orderEntity.payDate"
            type="number"
            auto-complete="off"
            placeholder="请输入发薪日期"
          ></el-input>
        </el-form-item>
        <el-form-item label="订单价格">
          <el-input
            size="small"
            v-model="editForm.orderEntity.orderPrice"
            auto-complete="off"
            placeholder="请输入订单价格"
          ></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            size="small"
            v-model="editForm.orderEntity.remark"
            auto-complete="off"
            placeholder="请输入备注"
          ></el-input>
        </el-form-item>
        <el-form-item label="人员">
          <div v-for="(item, i) in orderPeople" :key="i">
            <div class="agent">
              <el-select
                size="small"
                v-model="item.agentId"
                placeholder="请选择代理"
                style="width：80%;"
                @change="agentIdChanged(item)"
              >
                <el-option
                  v-for="type in agentIdArr"
                  :label="type.agentName"
                  :value="type.agentId"
                  :key="type.agentId"
                ></el-option>
              </el-select>
              <!-- <button @click="addPeople">添加</button> -->
              <i
                class="el-icon-circle-plus-outline"
                v-if="i == 0"
                @click="addPeople"
              ></i>
              <i
                class="el-icon-remove-outline"
                v-if="i != 0"
                @click="removePeople(i)"
              ></i>
            </div>
            <ul
              class="disabeld"
              v-for="(it, j) in item.disabled"
              :key="it.disabilityId + j"
            >
              <div>
                <el-select
                  size="small"
                  v-model="it.disabilityId"
                  clearable
                  placeholder="请选择残疾人"
                >
                  <el-option
                    v-for="type in item.agentIdDisabledArr"
                    :label="type.disabilityName"
                    :value="type.disabilityId"
                    :key="type.disabilityId"
                  ></el-option>
                </el-select>
              </div>
              <div>
                <el-date-picker
                  size="small"
                  v-model="it.orderDate"
                  type="monthrange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  @change="disDataChange(it)"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </div>
              <div>
                <el-input
                  size="small"
                  v-model="it.disabilityCost"
                  placeholder="请输入金额"
                ></el-input>
              </div>
              <!-- <button v-show="j==0" @click="addDisabled(i,j)">添加</button> -->
              <!-- <button v-show="j!=0" @click="delDisabeld(i,j)">删除</button> -->
              <i
                class="el-icon-remove-outline disabledButton"
                v-show="j != 0"
                @click="delDisabeld(i, j)"
              ></i>
              <i
                class="el-icon-circle-plus-outline disabledButton"
                v-show="j == 0"
                @click="addDisabled(i, j)"
              ></i>
            </ul>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button
          size="small"
          type="primary"
          :loading="loading"
          class="title"
          @click="submitForm('editForm')"
          >保存</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listCustomeweOnline,
  listAgentOnline,
  addOrder,
  editOrder,
  listOrder,
  agentGetDis,
  getOrderDetail,
} from "../../api/userMG";
import Pagination from "../../components/Pagination";
import {
  provinceAndCityData,
  regionData,
  provinceAndCityDataPlus,
  regionDataPlus,
  CodeToText,
  TextToCode,
} from "element-china-area-data";
import Axios from "axios";
import { getCookie } from '../../utils/util';
export default {
  data() {
    return {
      isShowOrderMoney:false,
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: "添加",
      orderId: "", // 订单ID，用来请求订单详情的
      editForm: {
        orderEntity: {
          customerId: "", // 客户id
          affiliatedProvinceId: "", // 挂靠省id
          affiliatedProvinceTxt: "", // 挂靠省描述
          affiliatedCityId: "", // 挂靠市区id
          affiliatedCityTxt: "", // 挂靠市区描述
          remark: "", // 备注
          orderPrice: "", // 订单价格
          payDate:"", // 发薪日期
          wage:"", // 工资
        },
        orderDisabilityEntityList: [
          {
            //             agentId: "", // 代理人id
            //             disabilityId:1,//（残疾人id）
            //             orderStartDate:"2021-01-01",//（挂靠开始月）
            //             orderEndDate:"2021-05-01", //（挂靠结束月）
            //             disabilityCost:500 //（成本，残疾人价格）
          },
        ],
      },
      orderPeople: [
        {
          agentId: "",
          agentIdDisabledArr: [],
          disabled: [
            {
              disabilityId: "",
              orderStartDate: "",
              orderDate: "",
              orderEndDate: "",
              disabilityCost: "",
            },
          ],
        },
      ],
      // rules表单验证
      rules: {},
      formInline: {
        pageNum: 1,
        pageSize: 10,
        affiliatedProvinceId: "", // 挂靠省Id
        affiliatedCityId: "", // 挂靠城市Id
        customerId: "", // 客户ID
        agentId: "", // 代理ID
        startDate: "", // 挂卡结束时间
        endDate: "", // 挂靠开始时间
        agentId: "", // 代理人ID
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
      // 搜索的代理的ID
      agentIdArr: [],
      // 搜索的客户的ID
      customerIdArr: [],
      options: provinceAndCityData, // 备选的地区
      selectedOptions: [], // 选中的地区
      selectedOptions2: [],
      dataValue: "", // 时间
      editDisabledArr:[], // 专门用来保存的编辑的时候原来残疾人的数组，用来和新的数组对比用的;
    };
  },
  // 注册组件
  components: {
    Pagination,
  },
  /**
   * 数据发生改变
   */
  mounted() {
    this.isShowOrderMoney = getCookie("isShowIndex") == 1;
    provinceAndCityData[0].children = regionData[0].children[0].children; // 北京市
    provinceAndCityData[1].children = regionData[1].children[0].children; // 天津市
    provinceAndCityData[8].children = regionData[8].children[0].children; // 上海市
    provinceAndCityData[21].children = regionData[21].children[0].children; // 重庆市
    regionData[21].children[1].children.map((item) => {
      provinceAndCityData[21].children.push(item);
    });
  },
  /**
   * 创建完毕
   */
  created() {
    this.getCustomerIdArr();
    this.getdata(this.formInline);
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    unique(arr) {
      var arr1 = []; // 新建一个数组来存放arr中的值
      for (var i = 0, len = arr.length; i < len; i++) {
        if (arr1.indexOf(arr[i]) === -1) {
          arr1.push(arr[i]);
        }
      }
      return arr1;
    },
    // 计算代理的名称
    computerAgentName(row) {
      var agentNameArr = [];
      row.orderDisabilityEntityList.map((item) => {
        agentNameArr.push(item.agentName);
      });
      agentNameArr = this.unique(agentNameArr); // 去重复之后添加进去
      return agentNameArr.join(",");
    },
    // 添加个人员
    addPeople() {
      this.orderPeople.push({
        agentId: "",
        agentIdDisabledArr: [],
        disabled: [
          {
            disabilityId: "",
            orderStartDate: "",
            orderEndDate: "",
            orderDate: "",
            disabilityCost: "",
          },
        ],
      });
    },
    removePeople(index) {
      this.orderPeople.splice(index, 1);
    },
    // 给代理添加联系人
    addDisabled(i) {
      this.orderPeople[i].disabled.push({
        disabilityId: "",
        orderStartDate: "",
        orderEndDate: "",
        disabilityCost: "",
      });
    },
    // 给代理删除联系人
    delDisabeld(i, j) {
      this.orderPeople[i].disabled.splice(j, 1);
    },
    // 代理改变了
    agentIdChanged(item) {
      item.disabled.map((it) => {
        it.disabilityId = "";
      });
      var flage = 0;
      this.orderPeople.map((it) => {
        if (it.agentId == item.agentId) {
          flage++;
        }
      });
      if (flage >= 2) {
        this.$message.error("请选择不同的代理人");
        return;
      }
      agentGetDis({
        agentId: item.agentId,
      }).then((res) => {
        if (res.status == 200) {
          // 通过循环，得到
          this.orderPeople.map((it) => {
            if (it.agentId == item.agentId) {
              it.agentIdDisabledArr = res.data;
            }
          });
        }
      });
    },
    // 获取进行中的客户的数据
    getCustomerIdArr() {
      listCustomeweOnline().then((res) => {
        //console.log(res);
        if (res.status == 200) {
          this.customerIdArr = res.data;
        }
      });
      listAgentOnline().then((res) => {
        if (res.status == 200) {
          this.agentIdArr = res.data;
        }
      });
    },
    // 获取订单列表
    getdata(parameter) {
      //console.log(parameter);
      /***
       * 调用接口，注释上面模拟数据 取消下面注释
       */
      listOrder(parameter)
        .then((res) => {
          this.loading = false;
          //console.log(res);
          if (res.status != 200) {
            this.$message({
              type: "info",
              message: res.msg,
            });
          } else {
            this.listData = res.data.list;
            // 分页赋值
            this.pageparm.currentPage = Number(this.formInline.pageNum);
            this.pageparm.pageSize = Number(this.formInline.pageSize);
            this.pageparm.total = Number(res.data.total);
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error("数据加载失败，请稍后再试！");
        });
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.pageNum = parm.currentPage;
      this.formInline.pageSize = parm.pageSize;
      this.getdata(this.formInline);
    },
    // 选择时间的时候
    dataChange() {
      if (this.dataValue) {
        this.formInline.startDate = this.dataValue[0];
        this.formInline.endDate = this.dataValue[1];
      } else {
        this.formInline.startDate = "";
        this.formInline.endDate = "";
      }
    },
    // 残疾人，选择的挂靠时间
    disDataChange(it) {
      it.orderStartDate = it.orderDate[0];
      it.orderEndDate = it.orderDate[1];
    },
    // 搜索事件
    search() {
      //console.log(this.formInline);
      this.formInline.pageNum = 1;
      this.getdata(this.formInline);
    },
    //显示编辑界面
    handleEdit: function (index, row) {
      this.editFormEmpty(); // 点击编辑，先清空页面
      this.editFormVisible = true;
      if (row != undefined && row != "undefined") { // 点击编辑按钮
        //console.log(row);
        this.title = "修改";
        // 获取订单的详情
        this.editForm.orderEntity.orderId = row.orderEntity.orderId;
        this.editForm.orderEntity.customerId = row.orderEntity.customerId;
        this.editForm.orderEntity.orderPrice = row.orderEntity.orderPrice;
        this.editForm.orderEntity.remark = row.orderEntity.remark;
        this.editForm.orderEntity.affiliatedProvinceId =
          row.orderEntity.affiliatedProvinceId;
        this.editForm.orderEntity.affiliatedProvinceTxt =
          row.orderEntity.affiliatedProvinceTxt;
        this.editForm.orderEntity.affiliatedCityId =
          row.orderEntity.affiliatedCityId;
        this.editForm.orderEntity.affiliatedCityTxt =
          row.orderEntity.affiliatedCityTxt;
        this.editForm.orderEntity.wage = row.orderEntity.wage; // 工资
        this.editForm.orderEntity.payDate = row.orderEntity.payDate; // 发薪日期
        this.selectedOptions2.push(
          row.orderEntity.affiliatedProvinceId,
          row.orderEntity.affiliatedCityId
        );
        var newArr = [];
        // 把代理人和残疾人的数据格式化
        this.editDisabledArr = []; // 保存编辑的时候，原来的残疾人数组
        row.orderDisabilityEntityList.map((item) => {
          this.editDisabledArr.push(item);
          var ishasThisAgentId = newArr.some((it) => {
            return item.agentId == it.agentId;
          });
          if (ishasThisAgentId) {
            // 如果有了
            newArr.map((it) => {
              if (it.agentId == item.agentId) {
                it.disabled.push({
                  disabilityId: item.disabilityId,
                  orderEndDate: item.orderEndDate,
                  orderStartDate: item.orderStartDate,
                  disabilityCost: item.disabilityCost,
                  orderDate: [item.orderStartDate, item.orderEndDate],
                  status:item.status,
                  customerId:item.customerId,
                  orderDisabilityId:item.orderDisabilityId
                });
              }
            });
          } else {
            newArr.push({
              agentId: item.agentId,
              agentIdDisabledArr: [],
              disabled: [
                {
                  disabilityId: item.disabilityId,
                  orderStartDate: item.orderStartDate,
                  orderEndDate: item.orderEndDate,
                  orderDate: [item.orderStartDate, item.orderEndDate],
                  disabilityCost: item.disabilityCost,
                  status:item.status,
                  customerId:item.customerId,
                  orderDisabilityId:item.orderDisabilityId
                },
              ],
            });
          }
        });
        //console.log(newArr);
        // 添加残疾人数据
        newArr.map((item) => {
          agentGetDis({
            agentId: item.agentId,
          }).then((res) => {
            if (res.status == 200) {
              // 通过循环，得到
              item.agentIdDisabledArr = res.data;
            }
            // 通过every查看是不是都请求完成了
            var isComplete = newArr.every((it) => {
              return it.agentIdDisabledArr.length != 0;
            });
            // 完成之后赋值
            if (isComplete) {
              this.orderPeople = newArr;
            }
          });
        });
      } else {
        this.title = "添加";
        delete this.editForm.orderEntity.orderId;
      }
    },
    // 编辑、增加页面保存方法
    submitForm(editData) {
      this.$refs[editData].validate((valid) => {
        if (valid) {
          //console.log(this.editForm)
          //console.log(this.editForm.orderEntity);
          if (!("orderId" in this.editForm.orderEntity)) {  // 新增订单
            // 数据扁平化
            var orderDisabilityEntityList = [];
            this.orderPeople.map((item) => {
              item.disabled.map((it) => {
                orderDisabilityEntityList.push({
                  disabilityId: it.disabilityId,
                  orderStartDate: it.orderStartDate,
                  orderEndDate: it.orderEndDate,
                  disabilityCost: it.disabilityCost,
                  agentId: item.agentId,
                });
              });
            });
            this.editForm.orderDisabilityEntityList = orderDisabilityEntityList;
            this.editForm.orderEntity.wage = this.editForm.orderEntity.wage != "" ? Number(this.editForm.orderEntity.wage) : ""; // 格式化成位数字格式
            this.editForm.orderEntity.payDate = this.editForm.orderEntity.payDate != "" ? Number(this.editForm.orderEntity.payDate) : ""; //格式化成为数字格式
            // return;
            addOrder(this.editForm)
              .then((res) => {
                this.editFormVisible = false;
                this.loading = false;
                if (res.status == "200") {
                  this.getdata(this.formInline);
                  this.editFormEmpty();
                  this.$message({
                    type: "success",
                    message: res.desc,
                  });
                } else {
                  this.$message({
                    type: "info",
                    message: res.desc,
                  });
                }
              })
              .catch((err) => {
                this.editFormVisible = false;
                this.loading = false;
                this.$message.error("接口调用失败，请稍后再试！");
              });
          } else { // 编辑订单
            // 数据扁平化
            var orderDisabilityEntityList = []; // 现在新的数据
            this.orderPeople.map((item) => {
              item.disabled.map((it) => {
                orderDisabilityEntityList.push({
                  status:it.status,
                  orderId:this.editForm.orderEntity.orderId, // 给每个都添加一个订单id
                  disabilityId: it.disabilityId,
                  orderStartDate: it.orderStartDate,
                  orderEndDate: it.orderEndDate,
                  disabilityCost: it.disabilityCost,
                  agentId: item.agentId,
                  orderDisabilityId:it.orderDisabilityId,
                  customerId:it.customerId
                });
              });
            });
            
            // console.log("编辑的数据");
            // console.log(this.editForm);
            
            // isDelete:1,删除 2,未变 3,新增
            orderDisabilityEntityList.map(item=>{
              var notChange = this.editDisabledArr.some(it=>{
                return it.disabilityId == item.disabilityId && it.orderDisabilityId == item.orderDisabilityId
              })
              if(notChange){
                item.isDelete = 2;
              }
              var isAdd = this.editDisabledArr.every(it=>{
                return it.disabilityId != item.disabilityId
              })
              if(isAdd){
                item.isDelete = 3;
              }
            })
            var isDelArr = []; // 删除的单独给个数组
            this.editDisabledArr.map(item=>{
              var isDel = orderDisabilityEntityList.every(it=>{
                return (it.disabilityId != item.disabilityId || it.orderDisabilityId != item.orderDisabilityId)
              })
              if(isDel){
                item.isDelete = 1;
                isDelArr.push(item);
              }
            })
            isDelArr.map(item=>{
              orderDisabilityEntityList.push(item);
            })
            console.log(this.editDisabledArr); // 原来的数据
            console.log(orderDisabilityEntityList); // 现在的数据

            // return;
            // console.log(this.editForm);
            this.editForm.orderEntity.wage = this.editForm.orderEntity.wage != "" ? Number(this.editForm.orderEntity.wage) : ""; // 格式化成位数字格式
            this.editForm.orderEntity.payDate = this.editForm.orderEntity.payDate != "" ? Number(this.editForm.orderEntity.payDate) : ""; //格式化成为数字格式
            this.editForm.orderDisabilityEntityList = orderDisabilityEntityList;
            
            editOrder(this.editForm)
              .then((res) => {
                this.editFormVisible = false;
                this.loading = false;
                if (res.status == "200") {
                  this.getdata(this.formInline);
                  this.$message({
                    type: "success",
                    message: res.desc,
                  });
                } else {
                  this.$message({
                    type: "info",
                    message: res.desc,
                  });
                }
              })
              .catch((err) => {
                this.editFormVisible = false;
                this.loading = false;
                this.$message.error("接口调用失败，请稍后再试！");
              });
          }
        } else {
          return false;
        }
      });
    },



    // 清空数据
    editFormEmpty(){
      this.editForm.orderEntity.customerId = "";
      this.editForm.orderEntity.affiliatedProvinceId = "";
      this.editForm.orderEntity.affiliatedProvinceTxt = "";
      this.editForm.orderEntity.affiliatedCityId = "";
      this.editForm.orderEntity.affiliatedCityTxt = "";
      this.editForm.orderEntity.remark = "";
      this.editForm.orderEntity.orderPrice = "";
      this.editForm.orderEntity.wage = "";
      this.editForm.orderEntity.payDate = "";
      this.editForm.orderDisabilityEntityList = [];
      this.selectedOptions2 = []; // 清空挂靠地区
      this.orderPeople = [
        {
          agentId: "",
          agentIdDisabledArr: [],
          disabled: [
            {
              disabilityId: "",
              orderStartDate: "",
              orderDate: "",
              orderEndDate: "",
              disabilityCost: "",
            },
          ],
        },
      ]
    },
    // 关闭编辑、增加弹出框
    closeDialog() {
      this.editFormVisible = false;
    },
    // 地区选择完成之后
    handleChange() {
      // //console.log(this.selectedOptions);
      var checkNode = this.$refs.shengshi.getCheckedNodes();
      if (checkNode.length == 0) {
        this.formInline.affiliatedProvinceId = ""; // 省
        this.formInline.affiliatedCityId = ""; // 市
      } else {
        this.formInline.affiliatedProvinceId = checkNode[0].parent.value; // 省
        this.formInline.affiliatedCityId = checkNode[0].value; // 市
      }
    },
    gkHandleChange() {
      var checkNode = this.$refs.guakaoSS.getCheckedNodes();
      if (checkNode.length == 0) {
        this.editForm.orderEntity.affiliatedProvinceId = ""; // 省
        this.editForm.orderEntity.affiliatedProvinceTxt = "";
        this.editForm.orderEntity.affiliatedCityId = ""; // 市
        this.editForm.orderEntity.affiliatedCityTxt = ""; // 市
      } else {
        this.editForm.orderEntity.affiliatedProvinceId =
          checkNode[0].parent.value; // 省
        this.editForm.orderEntity.affiliatedProvinceTxt =
          checkNode[0].parent.label;
        this.editForm.orderEntity.affiliatedCityId = checkNode[0].value; // 市
        this.editForm.orderEntity.affiliatedCityTxt = checkNode[0].label; // 市
      }
    },
  },
};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
/deep/ .el-select {
  width: 100%;
}
/deep/ .el-cascader--small {
  width: 100%;
}
/deep/ .el-range-editor--small.el-input__inner {
  width: 240px;
}
.agent {
  width: 40%;
}
.disabeld {
  display: flex;
  justify-content: center;
  align-content: center;
}
.disabeld > div {
  margin: 0 5px;
}
/deep/ .agent .el-select {
  width: 80%;
}
/deep/ .disabledButton {
  line-height: 41px;
  margin-left: 5px;
}
</style>


